<template>
	<view class="package" style="box-shadow: 1px 2px 4px 0px rgba(204,204,204,0.5);padding-bottom: 0px;">
		<view class="title">动态</view>
		<view class="space-between trends" v-for="(item,index) in orderLists" :key='item.id'>
			<view class="center left_trend">
				<image :src="item.avatar" mode=""></image>
				<view>
					<text>{{item.nickname}}</text>
					<text>{{item.createtime}}</text>
				</view>
			</view>
			<view class="right_trend">
				{{item.memo}}
			</view>
		</view>
		<view style="margin: 15rpx auto;justify-content: center;" v-if="orderLists.length<1" class="center">
			<image :src="Empty" mode=""
			 style="width: 200rpx;height: 200rpx;"></image>
		</view>
		<view class="more" @click="isLoading?loadMore():''"><text>{{isLoading?'查看更多':'暂无更多'}}</text>
		<uni-icons type="bottom" size="22" color="#666" v-if="isLoading"></uni-icons></view>
	</view>
</template>

<script setup lang="ts">
	import { onLoad } from '@dcloudio/uni-app';
	import { toPublish } from '@mqtt';
	import { Empty } from '@/utils/Static';
	import { ref} from 'vue';
	import {teamdynamic} from '@/gql/group';
	const props = defineProps({
	  type: { type: String },
	});
	const teamOrder=ref('')
	const lastPage = ref(1);
	const currentPage = ref(1);
	const orderLists = ref([]);
	
	const isLoading = ref(false); 
	onLoad((pearm)=>{
		teamOrder.value=pearm.id
		dynamic()
	})
	function dynamic(){
		const payload = {
		  query: teamdynamic,
		  variables: {
			bao_id: Number(teamOrder.value),
			page: currentPage.value,
		  },
		};
		toPublish(
		  'ql/store/getBaoLogList',
		  payload,
		  (obj: any) => {
		    const { bao_log_list } = obj.data;
			orderLists.value = [...orderLists.value, ...bao_log_list.list];
			lastPage.value = bao_log_list.lastpage;
			if(bao_log_list.lastpage>currentPage.value){
				isLoading.value=true
			}
		  }
		);
	}
	/**
	 * 加载更多
	 */
	function loadMore() {
	  if (currentPage.value < lastPage.value) { 
	    currentPage.value++;
	    dynamic();
	  }else{
		  isLoading.value=false
	  }
	}
</script>

<style scoped lang="less">
	@import url('../groupBenefits/less/trends.less');
</style>